// pages/editaddress/editaddress.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        people: "",
        phone: "",
        location: "",
    },
    confirmaddress() {
        if (this.data.people == "") {
            wx.showToast({
                title: '收货人不能为空',
                icon: "none"
            });
        } else if (this.data.phone == "") {
            wx.showToast({
                title: '联系电话不能为空',
                icon: "none"
            });
        } else if (this.data.location == "") {
            wx.showToast({
                title: '详细地址不能为空',
                icon: "none"
            });
        } else {
            let addresslist = wx.getStorageSync('addresslist');
            if (!addresslist) {
                addresslist = [];
                addresslist.push({
                    name: this.data.people,
                    phone: this.data.phone,
                    location: this.data.location,
                })
                wx.setStorageSync('addresslist', addresslist)
                wx.navigateBack();
            } else {
                addresslist.push({
                    name: this.data.people,
                    phone: this.data.phone,
                    location: this.data.location,
                })
                wx.setStorageSync('addresslist', addresslist)
                wx.navigateBack();
            }
        }
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})